﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace iLangl.LanguageWire
{
	public class LWCompanyInfoConfiguration : ConfigurationSection
	{
		//Company Information
		private static ConfigurationProperty companyIdProperty;
		private static ConfigurationProperty companyNameProperty;
		private static ConfigurationProperty companyCountryProperty;
		private static ConfigurationProperty companyStateProperty;
		private static ConfigurationProperty companyCityProperty;
		private static ConfigurationProperty companyAddressProperty;
		private static ConfigurationProperty companyZipProperty;
		private static ConfigurationProperty companyCurrencyProperty;
		private static ConfigurationProperty companyPhoneProperty;

		//Billing Information
		private static ConfigurationProperty billingIdProperty;
		private static ConfigurationProperty billingCurrencyProperty;
		private static ConfigurationProperty billingCountryProperty;
		private static ConfigurationProperty billingCompanyNameProperty;
		private static ConfigurationProperty billingFirstNameProperty;
		private static ConfigurationProperty billingLastNameProperty;
		private static ConfigurationProperty billingEmailProperty;		
		private static ConfigurationProperty billingStreetAddressProperty;
		private static ConfigurationProperty billingStreetAddress2Property;
		private static ConfigurationProperty billingPostalCodeProperty;
		private static ConfigurationProperty billingCityProperty;

		//Primary Contact
		private static ConfigurationProperty contactIdProperty;
		private static ConfigurationProperty contactEmailProperty;
		private static ConfigurationProperty contactLastNameProperty;
		private static ConfigurationProperty contactFirstNameProperty;
		private static ConfigurationProperty contactPhoneProperty;
		private static ConfigurationProperty contactTitleProperty;

		private static LWCompanyInfoConfiguration instance;
		private static ConfigurationPropertyCollection properties;

		static LWCompanyInfoConfiguration()
		{
			//Billing

			billingIdProperty = new ConfigurationProperty(
			  "billingId",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);



			billingCountryProperty = new ConfigurationProperty(
			  "billingCountry",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);

			billingCompanyNameProperty = new ConfigurationProperty(
			  "billingCompany",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);

			billingFirstNameProperty = new ConfigurationProperty(
			  "billingFirstName",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			billingLastNameProperty = new ConfigurationProperty(
			  "billingLastName",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			billingEmailProperty = new ConfigurationProperty(
			  "billingEmail",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			billingStreetAddressProperty = new ConfigurationProperty(
			  "billingStreetAddress",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);

			billingStreetAddress2Property = new ConfigurationProperty(
			  "billingStreetAddress2",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			billingPostalCodeProperty = new ConfigurationProperty(
			  "billingPostalCode",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			billingCityProperty = new ConfigurationProperty(
			  "billingCity",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			billingCurrencyProperty = new ConfigurationProperty(
			  "billingCurrency",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);


			companyIdProperty = new ConfigurationProperty(
			  "companyId",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			companyNameProperty = new ConfigurationProperty(
			  "companyName",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			companyCountryProperty = new ConfigurationProperty(
			  "companyCountry",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			companyStateProperty = new ConfigurationProperty(
			  "companyState",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			companyCityProperty = new ConfigurationProperty(
			  "companyCity",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			companyAddressProperty = new ConfigurationProperty(
			  "companyAddress",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			companyZipProperty = new ConfigurationProperty(
			  "companyZip",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			companyCurrencyProperty = new ConfigurationProperty(
			  "companyCurrency",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			companyPhoneProperty = new ConfigurationProperty(
			  "companyPhone",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);

			contactIdProperty = new ConfigurationProperty(
			  "contactId",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			contactEmailProperty = new ConfigurationProperty(
			  "contactEmail",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			contactLastNameProperty = new ConfigurationProperty(
			  "contactLastName",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			contactFirstNameProperty = new ConfigurationProperty(
			  "contactFirstName",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			contactPhoneProperty = new ConfigurationProperty(
			  "contactPhone",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);
			contactTitleProperty = new ConfigurationProperty(
			  "contactTitle",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);

			properties = new ConfigurationPropertyCollection();

			properties.Add(billingIdProperty);
			properties.Add(billingCountryProperty);
			properties.Add(billingCompanyNameProperty);
			properties.Add(billingFirstNameProperty);
			properties.Add(billingLastNameProperty);
			properties.Add(billingEmailProperty);
			properties.Add(billingStreetAddressProperty);
			properties.Add(billingStreetAddress2Property);
			properties.Add(billingPostalCodeProperty);
			properties.Add(billingCityProperty);
			properties.Add(billingCurrencyProperty);

			properties.Add(companyIdProperty);
			properties.Add(companyNameProperty);
			properties.Add(companyCountryProperty);
			properties.Add(companyStateProperty);
			properties.Add(companyCityProperty);
			properties.Add(companyAddressProperty);
			properties.Add(companyZipProperty);
			properties.Add(companyCurrencyProperty);
			properties.Add(companyPhoneProperty);


			properties.Add(contactIdProperty);
			properties.Add(contactEmailProperty);
			properties.Add(contactLastNameProperty);
			properties.Add(contactFirstNameProperty);
			properties.Add(contactPhoneProperty);
			properties.Add(contactTitleProperty);
		}

		private static object mutex = new object();
		/// <summary>
		/// The instance of the TransportConfiguration.
		/// </summary>
		public static LWCompanyInfoConfiguration Instance
		{
			get
			{
				if (instance == null)
				{
					lock (mutex)
					{
						if (instance == null)
						{
							instance = ConfigurationManager.GetSection("LWCompanyInfoConfiguration") as LWCompanyInfoConfiguration;
						}
					}
				}
				return instance;
			}
		}

		# region Company info
		public String CompanyId
		{
			get
			{
				return base[companyIdProperty] as String;
			}
		}

		public String CompanyName
		{
			get
			{
				return base[companyNameProperty] as String;
			}
		}

		public String CompanyCountry
		{
			get
			{
				return base[companyCountryProperty] as String;
			}
		}
		
		public String CompanyState
		{
			get
			{
				return base[companyStateProperty] as String;
			}
		}
		
		public String CompanyCity
		{
			get
			{
				return base[companyCityProperty] as String;
			}
		}
		
		public String CompanyAddress
		{
			get
			{
				return base[companyAddressProperty] as String;
			}
		}
		
		
		public String CompanyZip
		{
			get
			{
				return base[companyZipProperty] as String;
			}
		}
		
		public String CompanyCurrency
		{
			get
			{
				return base[companyCurrencyProperty] as String;
			}
		}


		public String CompanyPhone
		{
			get
			{
				return base[companyPhoneProperty] as String;
			}
		}
		#endregion


		#region Billing


		public String BillingId
		{
			get
			{
				return base[billingIdProperty] as String;
			}
		}


		public String BillingCurrency
		{
			get
			{
				return base[billingCurrencyProperty] as String;
			}
		}

		public String BillingCountry
		{
			get
			{
				return base[billingCountryProperty] as String;
			}
		}

		public String BillingCompanyName
		{
			get
			{
				return base[billingCompanyNameProperty] as String;
			}
		}


		public String BillingFirstName
		{
			get
			{
				return base[billingFirstNameProperty] as String;
			}
		}

		public String BillingLastName
		{
			get
			{
				return base[billingLastNameProperty] as String;
			}
		}

		public String BillingEmail
		{
			get
			{
				return base[billingEmailProperty] as String;
			}
		}

		public String BillingStreetAddress
		{
			get
			{
				return base[billingStreetAddressProperty] as String;
			}
		}

		public String BillingStreetAddress2
		{
			get
			{
				return base[billingStreetAddress2Property] as String;
			}
		}

		public String BillingPostalCode
		{
			get
			{
				return base[billingPostalCodeProperty] as String;
			}
		}

		public String BillingCity
		{
			get
			{
				return base[billingCityProperty] as String;
			}
		}
		#endregion

		#region Contact Section
		public String ContactId
		{
			get
			{
				return base[contactIdProperty] as String;
			}
		}
		public String ContactEmail
		{
			get
			{
				return base[contactEmailProperty] as String;
			}
		}
		public String ContactLastName
		{
			get
			{
				return base[contactLastNameProperty] as String;
			}
		}

		public String ContactFirstName
		{
			get
			{
				return base[contactFirstNameProperty] as String;
			}
		}
		public String ContactPhone
		{
			get
			{
				return base[contactPhoneProperty] as String;
			}
		}
		public String ContactTitle
		{
			get
			{
				return base[contactTitleProperty] as String;
			}
		}
		#endregion

		protected override ConfigurationPropertyCollection Properties
		{
			get
			{
				return properties;
			}
		}
	}
}
